#include <bits/stdc++.h>
#include "graph.h"
using namespace std;
const int inf = 1e9;
struct node {
	int x, w;
};
vector<int> v2[205];
vector<node> v[205];
bool vis[205], fl[205][205];
int n, d[205], fr[205], fa[205], mx[205], son[205], last[205], ans[205], dis[205][205];
void upd(int c) {
	Move(1, c), Move(LastRoad(), Color());
	return;
}
void pre(int x) {
	d[x] = NumberOfRoads();
	fr[x] = LastRoad();
	mx[x] = max(mx[fa[x]], d[x]);
	for(int i = 1; i <= d[x]; i++)
		if(i ^ fr[x]) {
			Move(i, 2);
			if(Color() > 1)
				fl[x][i] = 1, v2[x].push_back(i), Move(LastRoad(), 2);
			else
				fa[++n] = x, v[x].push_back({n, i}), pre(n);
		}
	if(x > 1)
		Move(fr[x], 2);
	return;
}
void dfs(int x) {
	last[x] = 0;
	if(fa[fa[x]]) {
		memset(vis, 0, sizeof(vis));
		for(int i : v2[x]) {
			Move(i, 3);
			int tmp = LastRoad(), p = fa[fa[x]];
			Move(tmp, Color());
			if(!vis[tmp] && mx[p] >= tmp) {
				vis[tmp] = 1;
				Move(fr[x], 3), last[fa[x]] = LastRoad(), son[fa[x]] = x;
				Move(fr[fa[x]], 1), last[p] = LastRoad(), son[p] = fa[x];
				while(mx[p] >= tmp) {
					if(fl[p][tmp]) {
						Move(tmp, Color());
						if(Color() == 3)
							dis[p][x] = dis[x][p] = 1;
						Move(LastRoad(), Color());
					}
					if(p > 1)
						Move(fr[p], Color()), last[fa[p]] = LastRoad(), son[fa[p]] = p, p = fa[p];
					else
						break;
				}
				while(last[p])
					Move(last[p], Color()), p = son[p];
			}
		}
	}
	for(auto i : v[x])
		Move(i.w, 1), dfs(i.x);
	if(x > 1)
		Move(fr[x], 1);
	return;
}
void Inspect(int R) {
	pre(n = 1);
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= n; j++)
			if(i ^ j)
				dis[i][j] = inf;
			else
				dis[i][j] = 0;
	for(int i = 1; i <= n; i++)
		for(auto j : v[i])
			dis[i][j.x] = dis[j.x][i] = 1;
	dfs(1);
	for(int k = 1; k <= n; k++)
		for(int i = 1; i <= n; i++)
			for(int j = 1; j <= n; j++)
				dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
	for(int i = 1; i < n; i++)
		for(int j = i + 1; j <= n; j++)
			if(dis[i][j] < inf)
				ans[dis[i][j]]++;
	for(int i = 1; i <= R; i++)
		Answer(i, ans[i]);
	return;
}